package com.sun.showcase.utils;

import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**物流轨迹
 *
 */
public class OrderTraces {
	private String EBusinessID;//电商用户ID
	private String ShipperCode;//快递公司编码
	private String ShipperName;//快递公司编码
	private String Success;//成功与否
	private String LogisticCode;//物流运单号
	private String State;//物流状态: 2-在途中，3-签收,4-问题件
	private String Reason;
	private List<Traces> Traces;
	private static Map<String,String> shipperMap = new HashMap<String,String>();
	static {
		shipperMap.put("DBL","德邦");
		shipperMap.put("EMS","EMS");
		shipperMap.put("HFWL","汇丰物流");
		shipperMap.put("HHTT","天天快递");
		shipperMap.put("HTKY","百世汇通");
		shipperMap.put("QFKD","全峰快递");
		shipperMap.put("SF","顺丰快递");
		shipperMap.put("ST","速通物流");
		shipperMap.put("STO","申通快递");
		shipperMap.put("UC","优速快递");
		shipperMap.put("YD","韵达快递");
		shipperMap.put("YTKD","运通快递");
		shipperMap.put("YTO","圆通速递");
		shipperMap.put("ZTO","中通速递");
	}
	public String getEBusinessID() {
		return EBusinessID;
	}
	public void setEBusinessID(String eBusinessID) {
		EBusinessID = eBusinessID;
	}
	public String getShipperCode() {
		return ShipperCode;
	}
	public void setShipperCode(String shipperCode) {
		ShipperCode = shipperCode;
	}
	public String getSuccess() {
		return Success;
	}
	public void setSuccess(String success) {
		Success = success;
	}
	public String getLogisticCode() {
		return LogisticCode;
	}
	public void setLogisticCode(String logisticCode) {
		LogisticCode = logisticCode;
	}
	public String getState() {
		return State;
	}
	public void setState(String state) {
		State = state;
	}
	public List<Traces> getTraces() {
		return Traces;
	}
	public void setTraces(List<Traces> traces) {
		Traces = traces;
	}
	public String getShipperName() {
		if(shipperMap == null || !shipperMap.containsKey(this.getShipperCode())){
			return "其他快递";
		}
		return shipperMap.get(this.getShipperCode());
	}
	public void setShipperName(String shipperName) {
		ShipperName = shipperName;
	}
	public String getReason() {
		return Reason;
	}
	public void setReason(String reason) {
		Reason = reason;
	}
	/**
	 * 排序
	 */
	public void reverseTraces(){
		if(Traces == null || Traces.size()==0){
			return;
		}
		Collections.sort(Traces, new Comparator<Traces>() {
			@Override
			public int compare(Traces o1, Traces o2) {
				return DateUtils.parse(DateUtils.format2, o2.getAcceptTime()).compareTo(DateUtils.parse(DateUtils.format2, o1.getAcceptTime()));
			}
		});
	}
	
	
}
